import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import i18n, { initI18n } from './i18n'
import App from './App.vue'
import HomeView from './views/HomeView.vue'
import AboutView from './views/AboutView.vue'

const routes = [
  { path: '/', component: HomeView },
  { path: '/about', component: AboutView }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 创建应用
const app = createApp(App)

// 注册插件
app.use(router)
app.use(i18n)
app.use(ElementPlus)

// 初始化 i18n（确保词条先加载，然后再挂载应用）
initI18n().then(() => {
  app.mount('#app')
}).catch((error) => {
  console.error('应用初始化失败:', error)
  // 即使失败也挂载应用，显示错误信息
  app.mount('#app')
})

